class PurchaseOrderLine {
  String? orderId;
  String? lineno;
  String? releaseno;
  String? materialcode;
  String? name;
  String? productQty;
  String? productUom;
  String? deliverydate;
  String? receivedate;
  String? planeddeliverydate;
  String? priceUnit;
  String? priceSubtotal;

  PurchaseOrderLine({
    this.orderId,
    this.lineno,
    this.releaseno,
    this.materialcode,
    this.name,
    this.productQty,
    this.productUom,
    this.deliverydate,
    this.receivedate,
    this.planeddeliverydate,
    this.priceUnit,
    this.priceSubtotal,
  });

  PurchaseOrderLine copyWith({
    String? orderId,
    String? lineno,
    String? releaseno,
    String? materialcode,
    String? name,
    String? productQty,
    String? productUom,
    String? receivedate,
    String? priceUnit,
  }) {
    return new PurchaseOrderLine(
      orderId: orderId ?? this.orderId,
      lineno: lineno ?? this.lineno,
      releaseno: releaseno ?? this.releaseno,
      materialcode: materialcode ?? this.materialcode,
      name: name ?? this.name,
      productQty: productQty ?? this.productQty,
      productUom: productUom ?? this.productUom,
      receivedate: receivedate ?? this.receivedate,
      priceUnit: priceUnit ?? this.priceUnit,
    );
  }

  @override
  String toString() {
    return '''PurchaseOrderLine{
      orderId: orderId,
      lineno: lineno,
      releaseno: releaseno,
      materialcode: materialcode,
      name: name,
      productQty: productQty,
      productUom: productUom,
      receivedate: receivedate,
      priceUnit: priceUnit,
    }''';
  }

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      (other is PurchaseOrderLine &&
          runtimeType == other.runtimeType &&
          orderId == other.orderId &&
          lineno == other.lineno &&
          releaseno == other.releaseno &&
          materialcode == other.materialcode &&
          name == other.name &&
          productQty == other.productQty &&
          productUom == other.productUom &&
          receivedate == other.receivedate &&
          priceUnit == other.priceUnit);

  factory PurchaseOrderLine.fromMap(Map<String, dynamic> map) {
    return new PurchaseOrderLine(
      orderId:
          map['order_id'] != false ? map['order_id'].toString() as String? : "",
      lineno: map['lineno'] != false ? map['lineno'].toString() as String? : "",
      releaseno: map['releaseno'] != false
          ? map['releaseno'].toString() as String?
          : "",
      materialcode: map['default_code'] != false
          ? map['default_code'].toString() as String?
          : "",
      name: map['name'] != false ? map['name'].toString() as String? : "",
      productQty: map['product_uom_qty'] != false
          ? map['product_uom_qty'].toString() as String?
          : "",
      productUom:
          map['uom_id'] != false ? map['uom_id'][1].toString() as String? : "",
      deliverydate: map['deliverydate'] != false
          ? map['deliverydate'].toString() as String?
          : "",
      receivedate: map['receivedate'] != false
          ? map['receivedate'].toString() as String?
          : "",
      planeddeliverydate: map['planeddeliverydate'] != false
          ? map['planeddeliverydate'].toString() as String?
          : "",
      priceUnit: map['price_unit'] != false
          ? map['price_unit'].toString() as String?
          : "",
      priceSubtotal: map['price_tax'] != false
          ? map['price_tax'].toString() as String?
          : "",
    );
  }

  Map<String, dynamic> toMap() {
    // ignore: unnecessary_cast
    return {
      'orderId': this.orderId,
      'lineno': this.lineno,
      'releaseno': this.releaseno,
      'materialcode': this.materialcode,
      'name': this.name,
      'productQty': this.productQty,
      'productUom': this.productUom,
      'receivedate': this.receivedate,
      'priceUnit': this.priceUnit,
      'priceSubtotal': this.priceSubtotal,
    } as Map<String, dynamic>;
  }

  List toDomainList() {
    List list = [
      if (this.orderId != null && this.orderId != '')
        ['order_id', '=', int.parse(this.orderId!)],
    ];
    // if (list.length == 0) {
    //   list.add(['orderId', '!=', null]);
    // }
    // ignore: unnecessary_cast
    return list;
  }

  Map<String, dynamic> toOdooMap() {
    // ignore: unnecessary_cast
    return {
      'order_id': this.orderId,
      'lineno': this.lineno,
      'releaseno': this.releaseno,
      'materialcode': this.materialcode,
      'name': this.name,
      'product_qty': this.productQty,
      'product_uom': this.productUom,
      'receivedate': this.receivedate,
      'price_unit': this.priceUnit,
      'price_subtotal': this.priceSubtotal,
    } as Map<String, dynamic>;
  }

//</editor-fold>

}
